<template>
  <el-dialog
    width="1200px"
    :title="$t('m.shelves.shelve')"
    :visible.sync="popupVisible"
    :before-close="close"
  >
    <!-- tool start -->
    <el-form align="left" ref="form" :model="detail" label-width="120px" size="mini">
      <el-row>
        <el-col :span="8">
          <el-form-item :label="$t('m.shelves.shelvescode')">
            <el-input disabled v-model="detail.shelvescode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.in.ordernumber')">
            <el-input disabled v-model="detail.ordernumber"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.shelves.qccode')">
            <el-input disabled v-model="detail.qccode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.in.typename')">
            <el-select v-model="detail.typename" disabled></el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.in.warehouse')">
            <el-input maxlength="20" v-model="$store.state.basicInfo.warehouseInfo.name" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.in.consignor')">
            <el-select v-model="detail.consignorname" disabled></el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.in.suppliername')">
            <el-select v-model="detail.suppliername" disabled></el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('m.remark')">
            <el-input type="textarea" :rows="2" disabled></el-input>
          </el-form-item>
        </el-col>
        <template v-if="shelvesdate">
          <el-col :span="8">
            <el-form-item :label="$t('m.state')">
              <el-input maxlength="20" show-word-limit v-model="stateComputed" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('m.shelves.shelvesdateComputed')">
              <el-input maxlength="20" show-word-limit v-model="shelvesdateComputed" disabled></el-input>
            </el-form-item>
          </el-col>
        </template>
      </el-row>
    </el-form>
    <!-- tool end -->

    <!-- table start -->
    <el-row>
      <el-col :span="24">
        <el-table
          ref="table"
          :data="detail.shelvesdetail"
          stripe
          empty-text
          fit
          tooltip-effect="dark">
          <el-table-column align="center" type="index" :label="$t('m.index')" width="50"></el-table-column>
          <el-table-column align="center" prop="productspeccode" label="sku"></el-table-column>
          <el-table-column align="center" prop="suppliercode" label="supplierCode"></el-table-column>
          <el-table-column align="center" prop="productname" :label="$t('m.in.productname')"></el-table-column>
          <el-table-column align="center" prop="productspec" :label="$t('m.in.productspec')"></el-table-column>
          <el-table-column align="center" prop="quantity" :label="$t('m.shelves.quantity')"></el-table-column>
          <el-table-column align="center" prop="locationcode" :label="$t('m.shelves.locationcode')"></el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <!-- table end -->
    <el-row>
      <el-col :span="24">
        <el-button @click="close">{{$t('m.close')}}</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>
<script>
import common from '@/utils/common'
export default {
  name:'shelvescode-popup',
  props:['popupVisible', 'detail', 'shelvesdate'],
  data(){
    return {}
  },
  mounted(){},
  computed:{
    stateOptions(){
      return [
        { value:0, label:this.$t('m.shelves.state1') },
        { value:1, label:this.$t('m.shelves.state4') },
        { value:2, label:this.$t('m.shelves.state5') },
        { value:3, label:this.$t('m.shelves.state3') }
      ]
    },
    stateComputed(){
      return this.stateOptions[this.detail.state].label
    },
    shelvesdateComputed(){
      return common.timestampToTime(this.shelvesdate)
    }
  },
  methods:{
    close(){
      this.$emit('close')
    }
  }
}
</script>